<?php
namespace app\shoes\controller;
/** 控制器类引入区 **/

/** 模型类引入区 **/

use think\Db;
use app\common\model\ProductOrder;
use app\web\validate\Room;

/**
 * 商品订单控制器
 * @package app\api\controller
 */
class GoodsOrder extends Auth
{
    public $noNeedLogin = [];

    /**
     * 添加商品到购物车
     */
    public function create_order()
    {
        if ($this->request->isPost()) {
            $getData = $this->request->post();
            $validate = new Room();
            if (!$validate->scene('cart')->check($getData)) {
                $this->result($validate->getError(), '', 204);
            }
            $orderModel = new ProductOrder();
            $order_data = $orderModel->createOrder($getData, $this->userInfo);
            if ($order_data['status'] == true) {
                $getData['order_id'] = $order_data['order_id'];
                //下单打印小票
                //FeiEPrintService::printPc($getData,$this->userInfo);
                $this->result('添加成功', '', 200);
            }else{
                $this->result($order_data['msg'], '', 204);
            }
        } else {
            $this->result('添加失败', '', 204);

        }
    }




}
